//
//  GuiGeTopView.m
//  JiuJiuShangCheng
//
//  Created by jiujiukeji on 2018/7/18.
//  Copyright © 2018年 jiujiukeji. All rights reserved.
//

#import "GuiGeTopView.h"

@implementation GuiGeTopView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self setUpUI];
    }
    return self;
}
- (void)setUpUI
{
    WeakSelf
    self.goodsImg = [[UIImageView alloc] init];
    _goodsImg.layer.masksToBounds = YES;
    _goodsImg.layer.cornerRadius = 4;
    _goodsImg.layer.borderColor = globalGray.CGColor;
//    _goodsImg.image = UIImageNamed(@"pingjiaimg");
    _goodsImg.layer.borderWidth = 1;
    [self addSubview:_goodsImg];
    [_goodsImg mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self).offset(rateWidth(20));
        make.top.equalTo(self).offset(-rateHeight(25));
        make.size.mas_offset(CGSizeMake(rateHeight(220), rateHeight(220)));
    }];
    
    self.goodsNameLB = [UILabel labelWithText:@"" textColor:UIColorFromRGB(0x333333) fontSize:14];
    _goodsNameLB.numberOfLines = 0;
    [_goodsNameLB sizeToFit];
    [self addSubview:_goodsNameLB];
    [_goodsNameLB mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.goodsImg.mas_right).offset(rateWidth(20));
        make.top.equalTo(self).offset(rateHeight(20));
        make.width.mas_lessThanOrEqualTo(@(rateWidth(450)));
    }];
    
    self.originalPriceLB = [UILabel labelWithText:@"￥0.00" textColor:UIColorFromRGB(0x999999) fontSize:13];
    [_originalPriceLB sizeToFit];
    [self addSubview:_originalPriceLB];
    [_originalPriceLB mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.goodsNameLB);
        make.top.equalTo(weakSelf.goodsNameLB.mas_bottom).offset(rateHeight(20));
    }];
    UIView *line = [[UIView alloc] init];
    line.backgroundColor = UIColorFromRGB(0x999999);
    [self addSubview:line];
    [line mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.originalPriceLB).offset(-2);
        make.right.equalTo(weakSelf.originalPriceLB).offset(2);
        make.centerY.equalTo(weakSelf.originalPriceLB);
        make.height.equalTo(@(1));
    }];
    self.currentPriceLB = [UILabel labelWithText:@"￥0.00" textColor:navBarColor fontSize:20];
    self.currentPriceLB.font = [UIFont boldSystemFontOfSize:20];
    [self addSubview:_currentPriceLB];
    [_currentPriceLB mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(weakSelf.originalPriceLB.mas_bottom).offset(rateHeight(20));
        make.left.equalTo(weakSelf.goodsNameLB);
    }];
}

@end
